import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('DestoryHook')
export class DestoryHook extends Component {

    private m_Hooks: Function[] = [];

    /**增加钩子方法 */
    public addHook(hook: Function) {
        this.m_Hooks.push(hook);
    }

    protected onDestroy(): void {
        for (let i = this.m_Hooks.length - 1; i >= 0; --i) {
            this.m_Hooks[i]();
        }
    }
}


